/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

//import com.umeng.analytics.pro.d;
import com.xuexiang.templateproject.bean.PageCourse;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import org.jetbrains.annotations.NotNull;

import java.util.List;

//import kotlin.jvm.internal.Intrinsics;
import com.xuexiang.templateproject.R;

import kotlin.Lazy;
//import kotlin.jvm.internal.Intrinsics;

public final class SubjectDialog extends Dialog {
    @NotNull

    /* renamed from: a  reason: collision with root package name */
    public List<PageCourse> mPageCourseList;
    @NotNull

    /* renamed from: b  reason: collision with root package name */
    public ItemOnClickListener mItemOnClickListener;
//    @NotNull

    /* renamed from: c  reason: collision with root package name */
//    public final Lazy mLazy;

    private Context mContext;
    public interface ItemOnClickListener {
        void itemOnClickListener(@NotNull PageCourse pageCourse);
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SubjectDialog(@NotNull Context context, @NotNull List<PageCourse> subjects, @NotNull ItemOnClickListener itemOnClickListener) {
        super(context, R.style.CustomDialog);
        mContext = context;
//        Intrinsics.checkNotNullParameter(context, "context");
//        Intrinsics.checkNotNullParameter(subjects, "subjects");
//        Intrinsics.checkNotNullParameter(itemOnClickListener, "itemOnClickListener");
        this.mPageCourseList = subjects;
        this.mItemOnClickListener = itemOnClickListener;
//        this.mLazy = LazyKt__LazyJVMKt.lazy(new SubjectDialog$adapter$2(this, context));
        setContentView(R.layout.layout_dialog_subject);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        Window window = getWindow();
        WindowManager.LayoutParams attributes = window != null ? window.getAttributes() : null;
        if (attributes != null) {
            attributes.gravity = 80;
        }
        Display defaultDisplay = getOwnerActivity().getWindowManager().getDefaultDisplay();//Sdk27ServicesKt.getWindowManager(context).getDefaultDisplay();
        if (attributes != null) {
            attributes.width = defaultDisplay.getWidth();
        }
        Window window2 = getWindow();
        if (window2 != null) {
            window2.setAttributes(attributes);
        }
        c();
        initView();
    }

    public static final void e(SubjectDialog this$0, View view) {
//        Intrinsics.checkNotNullParameter(this$0, "this$0");
        if (this$0.isShowing()) {
            this$0.dismiss();
        }
    }

    public static final boolean f(SubjectDialog this$0, View view, int i2, FlowLayout flowLayout) {
//        Intrinsics.checkNotNullParameter(this$0, "this$0");
        this$0.mItemOnClickListener.itemOnClickListener(this$0.mPageCourseList.get(i2));
        this$0.dismiss();
        return true;
    }
//
//    public final c a() {
//        return (c) this.mLazy.getValue();
//    }

    @NotNull
    public final List<PageCourse> b() {
        return this.mPageCourseList;
    }

    public final void c() {

        ((TagFlowLayout) findViewById(R.id.tagFlowLayout)).setAdapter(mTagAdapter);
    }

    public final void initView() {
        ((ImageView) findViewById(R.id.ivClose)).setOnClickListener(new View.OnClickListener() { // from class: d.m.b.g.g0
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                SubjectDialog.e(SubjectDialog.this, view);
            }
        });
        ((TagFlowLayout) findViewById(R.id.tagFlowLayout)).setOnTagClickListener(new TagFlowLayout.OnTagClickListener() { // from class: d.m.b.g.f0
            @Override // com.zhy.view.flowlayout.TagFlowLayout.c
            public final boolean onTagClick(View view, int i2, FlowLayout flowLayout) {
                boolean f2;
                f2 = SubjectDialog.f(SubjectDialog.this, view, i2, flowLayout);
                return f2;
            }
        });
    }
    TagAdapter mTagAdapter = new TagAdapter(mPageCourseList) {
        @Override
        public View getView(FlowLayout parent, int position, Object o) {
            TextView tv_date = (TextView)parent.inflate(mContext,R.layout.item_text_view,parent);
            tv_date.setText(mPageCourseList.get(position).component2());
            return tv_date;
        }
    };
}